package com.example.guethe.fireanalysisapp.util;

import android.content.Context;
import android.widget.Toast;


import com.example.guethe.fireanalysisapp.DApplication;
import com.example.guethe.fireanalysisapp.common.EasySubscriber;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * toast 简单封装
 * Created by zhaoshengping on 2017/8/26.
 */

public class ToastHelper {
    public static void show(Context context, String toastString) {
        Toast.makeText(context, toastString, Toast.LENGTH_SHORT).show();
    }

    public static void showOnMainThread (final Context context, final String toastString) {
        Observable.just(toastString)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new EasySubscriber<String>() {
                    @Override
                    protected void complete() {
                        Toast.makeText(context,toastString, Toast.LENGTH_SHORT).show();
                    }
                });
    }
    public static void show(String toastString) {
        Toast.makeText(DApplication.getAppContext(), toastString, Toast.LENGTH_SHORT).show();
    }
}
